<template>
   <div style="width:100%;height:100%;overflow: hidden;">
    <iframe ref="iframe1" style="width:100%;height:100%;border:none;"></iframe>
   </div>
   
</template>

<script lang="ts">
import { ref, watch,reactive,onMounted,h,onBeforeUnmount } from 'vue'
import { layer } from '@layui/layer-vue'
import MyHttp from "../../library/MyHttp";  
import MyWin from "../../library/MyWin"; 
import MyPage from "../../library/MyPage"; 
import {MyExcel} from "../../library/MyExcel"; 
import {MySimpleExport,TableColumn} from "../../library/MySimpleExport"; 
import MyAuth from "../../library/MyAuth"; 


import add from "../htpage/add.vue";  
 


export default {
  props:{
       data :Object
   }, 
   setup(prop:any, context:any) {
    const baseUrl="/htctl";
    const myWin=ref<any>(null);
    const iframe1=ref<any>(null);
    const postMessage=(data:any)=>{
      iframe1.value.contentWindow.postMessage(data,"*");
    }
    const fn=(e:any)=>{
      var funcName=e.data.funcName;
        var param=e.data.param;
        console.info("parent rev:");
        console.info(e);   
        switch(funcName){
          case "PMTInit":
            {
              let data={
                  funcName:"PMTLoadImge",
                  param:{url:prop.data}
                }
                postMessage(data);
            }
            break;
          case "PMTLoadImge":
            {
                
            }
            break;
            case "PMTRIGHT_MOUSE_DOWN":
            {
              let data={
                  funcName:"PMTSetMinRate",
                  param:{url:prop.data}
                }
                postMessage(data);
            }
            break;
        }
    }
    onMounted(() =>{  
      myWin.value=new MyWin();      
      window.addEventListener("message",fn,false); 
      iframe1.value.src=MyHttp.LayaUrl+ "/laya?t="+Math.random(); 
    });
    onBeforeUnmount(()=>{
      window.removeEventListener("message",fn,false);
    })
    return {
      myWin,
      iframe1
    }
  }
}
</script>
